package com.example.tetris.beans;

import com.example.tetris.ResourceTable;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;
import ohos.agp.utils.LayoutAlignment;
import ohos.agp.utils.TextAlignment;
import ohos.agp.window.dialog.ToastDialog;
import ohos.app.Context;

public class MyToastdialog {


  public static void showTip(Context context,String content){
      //创建对话框
      ToastDialog toastDialog =new ToastDialog(context);
      toastDialog.setAlignment(LayoutAlignment.CENTER);
      //透明
      toastDialog.setTransparent(true);

      //自定义样式
      DirectionalLayout directionalLayout = (DirectionalLayout) LayoutScatter.getInstance(context)
              .parse(ResourceTable.Layout_layout_toast,null,false);

      Text text = (Text)directionalLayout.findComponentById(ResourceTable.Id_msg_toast);
      text.setText(content);

      //装载布局
      toastDialog.setContentCustomComponent(directionalLayout);
      toastDialog.show();


  }
}
